package com.example.mp.modular.system.handler.messageHandler;

import com.example.mp.modular.system.handler.AbstractHandler;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutImageMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage;
import org.springframework.stereotype.Component;

import java.util.Map;

import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType;

@Component
public class ImageHandler extends AbstractHandler {

    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
                                    Map<String, Object> context, WxMpService weixinService,
                                    WxSessionManager sessionManager) {

            return buildXmlOutMessage(wxMessage,weixinService);
    }

    private WxMpXmlOutMessage buildXmlOutMessage(WxMpXmlMessage wxMessage, WxMpService service) {
        WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE()
                .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
                .mediaId(wxMessage.getMediaId())
                .build();
        return m;
    }

}
